package com.platform.common.bean;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Date;

import static java.time.LocalDateTime.*;

/**
 * describe:ActiveRecord模式
 * 全局公共实体类
 *
 * @author rainly
 * @date 2020/1/22
 * @time 11:54 下午
 */
@Data
public abstract class BaseEntity<T extends Model> extends Model {

    @TableField(value="create_by", fill = FieldFill.INSERT)
    protected String createBy;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @TableField(value="create_date", fill = FieldFill.INSERT)
    protected LocalDateTime createDate;

    @TableField(value="update_by", fill = FieldFill.INSERT_UPDATE)
    protected String updateBy;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @TableField(value="update_date", fill = FieldFill.INSERT_UPDATE)
    protected LocalDateTime updateDate;
}
